/* 
数据存储的工具函数模块
1. token处理  localStorage  ==> 自动登陆
2. 登陆user处理 sessionStorage
*/
const TOKEN_KEY = 'token_key'
const USER_KEY = 'user_key'

export const saveToken = (token) => localStorage.setItem(TOKEN_KEY, token)

export const getToken = () => localStorage.getItem(TOKEN_KEY)

export const removeToken = () => localStorage.removeItem(TOKEN_KEY)


export const saveUser = (user) => sessionStorage.setItem(USER_KEY, JSON.stringify(user))

export const getUser = () => JSON.parse(sessionStorage.getItem(USER_KEY))  // user对象或null

export const removeUser = () => sessionStorage.removeItem(USER_KEY)